package com.baturu.vin.ford.dal.dao;

import com.baturu.vin.ford.dto.FordImageDTO;
import com.baturu.vin.ford.dto.FordSortImageDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * 图片DAO(包含图形点选化)
 *
 * @Author: jiangxinlei
 * @Time: 2018-08-09 10:31
 **/
public interface FordImageDAO {

    @Select({"<script>",
            "select distinct imageCode, sortName from ford_sort_image_mapping",
            "where catalogCode = #{catalogCode}",
            "and sortName in ",
            "<foreach item='item' index='index' collection='sortNames' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<FordSortImageDTO> queryImageBySortName(@Param("sortNames") Collection<String> sortNames,
                                                @Param("catalogCode") String catalogCode);

    @Select({"select distinct data as imageCode, largeImagePaths as imagePath, label, chLabel",
            "from ford_section ",
            "where catalogCode = #{catalogCode} "})
    List<FordSortImageDTO> queryImageInfoByCatalog(@Param("catalogCode") String catalogCode);

    @Select({"<script>select distinct catalogCode, sectionCode, callout, topLeftX, topLeftY, bottomRightX, bottomRightY",
            "from ford_parts_hotpoints",
            "where catalogCode = #{catalogCode}",
            "and sectionCode in ",
            "<foreach item='item' index='index' collection='imageCodes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<FordImageDTO> queryHotPointsByCatalogAndSection(@Param("catalogCode") String catalogCode,
                                                         @Param("imageCodes") Collection<String> imageCodes);

}
